﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace ModelShredder
{
    public static class IEnumerableExtensions
    {
		public static DataTable ToDataTable<T>(this IEnumerable<T> source)
		{
			DefaultShredderOptionsProvider optionsProvider = new DefaultShredderOptionsProvider();

			return source.ToDataTable(optionsProvider.ProvideShredderOptions(typeof(T)));
		}

		public static DataTable ToDataTable<T>(this IEnumerable<T> source, ShredderOptions options)
		{
			Shredder<T> ms = new Shredder<T>(options, new InjectionObjectShredder(), new DefaultSchemaBuilder());

			return ms.Shred(source);
		}
    }
}
